<div style="font-size:12px;"></div>
<br />

<table id="<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>"></table>
<div id="<?php echo WacModuleHelper::getPagerId($invokeParams['moduleName'],$invokeParams['attachName']); ?>" ></div>

<script type="text/javascript">
    //<![CDATA[
    jQuery("#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>").jqGrid({
        datatype: "json",
        url: BASE_URL+"<?php echo $invokeParams['mainListUrl']; ?>",
        editurl: "<?php echo $invokeParams['moduleName']; ?>/doOperation",
        colNames:['id', '发生地', '类型', '单类型', '单编号', '物料名称', '数目', '单位', '单价', '加工费', '货币单位', '建立时间'],
        colModel:[
            {name:"id", index:"id", editable:false, hidden:true, width:30},
            {name:'factory_name', index:'factory_name', editable:false, width:100, align:"left"},
            {name:'statement_type_name', index:'statement_type_name', editable:false, width:100, align:"center"},
            {name:'biz_order_type_name', index:'biz_order_type_name', editable:false, width:100, align:"center"},
            {name:'biz_order_code', index:'biz_order_code', editable:false, width:100, align:"left"},
            {name:'goods_name', index:'goods_name', editable:false, width:100, align:"left"},
            {name:'goods_number', index:'goods_number', editable:false, width:100, align:"left"},
            {name:'goods_number_unit_code_name', index:'goods_number_unit_code_name', editable:false, width:100, align:"center"},
            {name:'goods_number_unit_price', index:'goods_number_unit_price', editable:false, width:100, align:"left"},
            {name:'processing_fee', index:'processing_fee', editable:false, width:100, align:"left"},
            {name:'currency_code_name', index:'currency_code_name', editable:false, width:100, align:"center"},
            {name:'created_at', index:'created_at', sorttype:'date', datefmt:'Y-m-d', width:150, editable:false, align:"center"}

        ],
        jsonReader : {
            root:"items",
            page: "currentPage",
            total: "totalPages",
            records: "totalRecords",
            userdata: "userdata",
            id: "id",
            repeatitems: false
        },
        rowNum:10,
        rowList:[10,20,30,40,50],
        sortname: 'id',
        sortorder: "desc",
        multiselect: false,
        viewrecords: true,
        pager: '#<?php echo WacModuleHelper::getPagerId($invokeParams['moduleName'],$invokeParams['attachName']); ?>',
        caption:"<?php echo $invokeParams['caption']; ?>列表",
        height: '100%',
        width: '100%',

        gridComplete: function(){
//            var ids = jQuery("#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>").jqGrid('getDataIDs');
//            var editUrl = BASE_URL + "<?php echo $invokeParams['moduleName']; ?>/edit";
//            var delUrl = BASE_URL + "<?php echo $invokeParams['moduleName']; ?>/delete";
//            for(var i=0;i < ids.length;i++){
//                var cl = ids[i];
//                be = "<input style='height:22px;width:28px;' type='button' value='编' onclick=\"jQuery('#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>').jqGrid('editRow','"+cl+"', true, null, <?php echo $invokeParams['moduleName']; ?>CallbackSave, '" + editUrl + "');\" />";
//                se = "<input style='height:22px;width:28px;' type='button' value='存' onclick=\"jQuery('#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>').jqGrid('saveRow', '"+cl+"', <?php echo $invokeParams['moduleName']; ?>CallbackSave, '" + editUrl + "', {}, null);\" />";
//                ce = "<input style='height:22px;width:28px;' type='button' value='消' onclick=\"jQuery('#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>').jqGrid('restoreRow', '"+cl+"');\" />";
//                de = "<input style='height:22px;width:28px;' type='button' value='删' onclick=\"jQuery('#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>').jqGrid('delGridRow', '"+cl+"', {url:'" + delUrl + "'});\" />";
//                jQuery("#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>").jqGrid('setRowData',ids[i],{
//                    act:be+se+ce+de
//                });
//            }
        },

        loadError : function(xhr,st,err){
            wacDebugLog("Type: "+st+"; Response: "+ xhr.status + " "+xhr.statusText);
        },

        loadComplete: function()
        {
            $(this).trigger("tabsload");   // inform tabs event listener
        }

    });
    jQuery("#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>").jqGrid('navGrid','#<?php echo WacModuleHelper::getPagerId($invokeParams['moduleName'],$invokeParams['attachName']); ?>',
    {edit:false, add:false, del:false, search:true, refresh:true, view:true, position:"left"},
    {afterSubmit: <?php echo $invokeParams['moduleName']; ?>CallbackValidate, afterComplete: <?php echo $invokeParams['moduleName']; ?>CallbackEdit},
    {afterSubmit: <?php echo $invokeParams['moduleName']; ?>CallbackValidate, afterComplete: <?php echo $invokeParams['moduleName']; ?>CallbackAdd},
    {afterComplete: <?php echo $invokeParams['moduleName']; ?>CallbackDel},
    {afterComplete: <?php echo $invokeParams['moduleName']; ?>CallbackSearch},
    {afterComplete: <?php echo $invokeParams['moduleName']; ?>CallbackView}
);

    function <?php echo $invokeParams['moduleName']; ?>CallbackValidate(response, postdata)
    {
        //    wacDebugLog("callbackEdit");

        wacAjaxData.response = eval('(' + response.responseText + ')');
        //    wacDebugLog($.dump(wacAjaxData.response));
        //    wacDebugLog($.dump(postdata));

        if(wacAjaxData.response.userdata.status == wacOperationStatus.Succss)
        {
            return [true, "", ""];
        }
        else
        {
            return [false, wacAjaxData.response.userdata.error_info];
        }
    }

    function <?php echo $invokeParams['moduleName']; ?>CallbackSave(response)
    {
        //    wacDebugLog("callbackSave");
        //    wacDebugLog("callbackSave");
        //    wacDebugLog($.dump($("#<?php echo WacModuleHelper::getListId($invokeParams['moduleName'],$invokeParams['attachName']); ?>").jqGrid('getGridParam', 'userData')));
        //    wacDebugLog(response.responseText);
        wacAjaxData.response = eval('(' + response.responseText + ')');
        if(wacAjaxData.response.userdata.status == wacOperationStatus.Succss)
        {
            return true;
        }
        else
        {
            showTips(wacAjaxData.response.userdata.error_info);
            return [false, wacAjaxData.response.userdata.error_info];
        }
    }

    function <?php echo $invokeParams['moduleName']; ?>CallbackEdit()
    {
        //    wacDebugLog("callbackEdit");
        //    wacDebugLog("callbackEdit");
    }

    function <?php echo $invokeParams['moduleName']; ?>CallbackAdd()
    {
        //    wacDebugLog("callbackAdd");
        //    wacDebugLog("callbackAdd");
    }

    function <?php echo $invokeParams['moduleName']; ?>CallbackDel()
    {
        //    wacDebugLog("callbackDel");
        //    wacDebugLog("callbackDel");
    }

    function <?php echo $invokeParams['moduleName']; ?>CallbackSearch()
    {
        //    wacDebugLog("callbackSearch");
        //    wacDebugLog("callbackSearch");
    }

    function <?php echo $invokeParams['moduleName']; ?>CallbackView()
    {
        //    wacDebugLog("callbackView");
    }

//]]>
</script>

<br /><br />